﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using Ebada.Platform.Model;
using Ebada.UI.Base;
using Ebada.Client;
using Ebada.Core;
using Ebada.Client.Platform;
namespace Ebada.Modules.Vehicle
{
    /// <summary>
    /// 违章记录编辑
    /// </summary>
    public partial class frmVehicleGasStationEdit : FormBase, IPopupFormEdit {
       

        public frmVehicleGasStationEdit() {
            InitializeComponent();
        }
        void dataBind() {

            this.txtGasStation.DataBindings.Add("EditValue", rowData, "GasStation");
            this.txtAdress.DataBindings.Add("EditValue", rowData, "Adress");
            this.txtCityCode.DataBindings.Add("EditValue", rowData, "CityCode");
            this.txtCityName.DataBindings.Add("EditValue", rowData, "CityName");
            this.txtRemark.DataBindings.Add("EditValue", rowData, "Remark");
        }
        #region IPopupFormEdit Members
        private VehicleGasStation rowData = null;

        public object RowData {
            get {
                return rowData;
            }
            set {
                if (value == null) return;
                if (rowData == null) {
                    this.rowData = value as VehicleGasStation;
                    dataBind();
                    InitComboBoxData();
                } else {
                    ConvertHelper.CopyTo<VehicleGasStation>(value as VehicleGasStation, rowData);
                    InitComboBoxData();
                }
            }
        }

        #endregion

        private void InitComboBoxData() {
            //IList<Activities> list= MainHelper.GetSqlMap<Activities>().GetListByWhere<Activities>(" where ProjectName='车辆项目' order by Act_ID");
            //txtAct_Name.Properties.DataSource = list;
        }
 
        private void btnOK_Click(object sender, EventArgs e)
        {
            if (txtGasStation.Text == "")
            {
                MessageBox.Show("油站名称不能为空。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                txtGasStation.Focus();
                return;
            }
            this.DialogResult = DialogResult.OK;
            this.Close();
        }

        private void txtCityName_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
        {
            Ebada.Client.Platform.Selector.frmCitySelector frm = new Ebada.Client.Platform.Selector.frmCitySelector();
            frm.StartPosition = FormStartPosition.CenterScreen;
            if (frm.ShowDialog() == DialogResult.OK)
            {
                txtCityName.Text = frm.City.cnName;
                txtCityCode.Text = frm.City.AreaCode;
                rowData.CityName = frm.City.cnName;
                rowData.CityCode = frm.City.AreaCode;
            }
        }

    }
}